package com.ltedu.common.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

/**
 * @className: LongJsonSerializer
 * @auther: Jerry
 * @date: 2020/12/7 17:28
 * @desctiption: TODO
 * @version: 1.0
 */
public class LongJsonSerializer extends JsonSerializer<Long> {

    /**
     * 序列化
     *
     * @param value              价值
     * @param jsonGenerator      json发电机
     * @param serializerProvider 序列化器供应商
     * @throws IOException ioexception
     */
    @Override
    public void serialize(Long value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        String text = (value == null ? null : String.valueOf(value));
        if (text != null) {
            jsonGenerator.writeString(text);
        }
    }
}
